#include <stdio.h>

void lookup_error(const char* input) {
    int the_int = 0;
    int balance = 0;

    for (int i = 0; input[i] != '\0'; ++i) {
        if (input[i] == '(') {
            balance++;
        } else if (input[i] == ')') {
            balance--;
        }
        // If balance goes negative, it means there's a closing parenthesis without a matching opening parenthesis.
        if (balance < 0) {
            break;
        }
    }

    // If balance is 0, all parentheses are properly enclosed.
    if (balance == 0) {
        the_int = 1;
    }

    // Print to check the result
    printf("the_int = %d\n", the_int);
}

int main() {
    lookup_error("()(())");  // Should print: the_int = 1
    lookup_error("((()))");  // Should print: the_int = 1
    lookup_error("(()))");   // Should print: the_int = 0
    lookup_error("((())");   // Should print: the_int = 0
    return 0;
}


